﻿namespace WMS6.Web.Inventory
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.InventoryMgtServiceRef;

    public class LotAttribute : BasePage
    {
        protected Button btnGoBack;
        protected DropDownList ddlLotAttr09;
        protected HtmlForm F5071;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlInputHidden hdnFrom;
        protected HtmlInputHidden hdnOwnerID;
        protected HtmlInputHidden hdnSkuID;
        protected HtmlInputHidden hdnType;
        protected Label lblExpiryDate;
        protected Label lblExternalLot;
        protected Label lblLot;
        protected Label lblLotAttribute;
        protected Label lblMsg;
        protected Label lblOwnerID;
        protected Label lblProuceDate;
        protected Label lblReceiptDate;
        protected Label lblSkuDescr;
        protected Label lblSkuID;
        protected Label lblVendorID;
        protected Label LotAttr01;
        protected Label LotAttr02;
        protected Label LotAttr03;
        protected Label LotAttr04;
        protected Label LotAttr05;
        protected Label LotAttr06;
        protected Label LotAttr07;
        protected Label LotAttr08;
        protected Label LotAttr09;
        protected Label LotAttr10;
        protected HtmlLink mycss;
        protected Label one1;
        protected ScriptManager ScriptManager1;
        protected TextBox txtExpiryDate;
        protected TextBox txtExternalLot;
        protected TextBox txtLot;
        protected TextBox txtLotAttr01;
        protected TextBox txtLotAttr02;
        protected TextBox txtLotAttr03;
        protected TextBox txtLotAttr04;
        protected TextBox txtLotAttr05;
        protected TextBox txtLotAttr06;
        protected TextBox txtLotAttr07;
        protected TextBox txtLotAttr08;
        protected TextBox txtLotAttr10;
        protected TextBox txtOwnerID;
        protected TextBox txtProuceDate;
        protected TextBox txtReceiptDate;
        protected TextBox txtSkuDescr;
        protected TextBox txtSkuID;
        protected TextBox txtVendorID;

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            switch (this.hdnFrom.Value)
            {
                case "query":
                    base.Response.Redirect("LotAttributeQuery.aspx", false);
                    break;

                case "list":
                    base.Response.Redirect("LotAttributeList.aspx?from=edit", false);
                    break;
            }
        }

        private void LoadData()
        {
            List<WMS6.Web.CommonMethodServiceRef.LotAttributeCodeInfo> LotAttributeCode = CommoneMethodServiceClientProxy.GetInstance().GetLotAttributCodeByGroupID("货品属性");
            this.ddlLotAttr09.DataSource = LotAttributeCode;
            this.ddlLotAttr09.DataTextField = "DESCR";
            this.ddlLotAttr09.DataValueField = "CODEID";
            this.ddlLotAttr09.DataBind();
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                this.SetLotAttributeInfo2Form();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                this.hdnFrom.Value = base.Request.QueryString["from"].ToString();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["OwnerID"]))
            {
                this.hdnOwnerID.Value = base.Request.QueryString["OwnerID"].ToString();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["SkuID"]))
            {
                this.hdnSkuID.Value = base.Request.QueryString["SkuID"].ToString();
            }
            if (base.Request.QueryString["type"] != null)
            {
                this.hdnType.Value = base.Request.QueryString["type"].ToString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        private void SetLotAttributeInfo2Form()
        {
            try
            {
                string lotID = base.Request.QueryString["ID"];
                LotAttributeInfo lotAttribute = InventoryMgtServiceClientProxy.GetInstance().GetLotAttributeInfoByID(lotID);
                base.DataEntityViewState = lotAttribute;
                if (lotAttribute != null)
                {
                    this.txtLot.Text = lotAttribute.Lot;
                    this.txtSkuID.Text = lotAttribute.SkuID;
                    this.txtOwnerID.Text = lotAttribute.OwnerID;
                    this.txtVendorID.Text = lotAttribute.VendorID;
                    this.txtSkuDescr.Text = lotAttribute.SkuDescr;
                    this.txtLotAttr01.Text = lotAttribute.LotAttr01;
                    this.txtLotAttr02.Text = lotAttribute.LotAttr02;
                    this.txtLotAttr03.Text = lotAttribute.LotAttr03;
                    this.txtLotAttr04.Text = lotAttribute.LotAttr04;
                    this.txtLotAttr05.Text = lotAttribute.LotAttr05;
                    this.txtLotAttr06.Text = lotAttribute.LotAttr06;
                    this.txtLotAttr07.Text = lotAttribute.LotAttr07;
                    this.txtLotAttr08.Text = lotAttribute.LotAttr08;
                    this.ddlLotAttr09.SelectedValue = lotAttribute.LotAttr09;
                    this.txtLotAttr10.Text = lotAttribute.LotAttr10;
                    this.txtProuceDate.Text = base.GetPreferenceShortDate(lotAttribute.ProduceDate);
                    this.txtExpiryDate.Text = base.GetPreferenceShortDate(lotAttribute.ExpiryDate);
                    this.txtExternalLot.Text = lotAttribute.ExternalLot;
                    this.txtReceiptDate.Text = base.GetPreferenceShortDate(lotAttribute.ReceiptDate);
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }
    }
}

